package com.kk.permission.huawei.actionutil;

import android.accessibilityservice.AccessibilityService;
import android.view.accessibility.AccessibilityNodeInfo;

import com.kk.R;
import com.kk.permission.accessibilityutils.NodeUtil;
import com.kk.permission.huawei.HuaweiActionUtil;
import com.kk.permission.huawei.HuaweiTool;
import com.kk.permission.utils.callershow.CallerShowUtils;

import java.util.HashMap;

public class HuaweiModifySystemUtil {
    private final String STEP1 = "step1";
    private final String STEP2 = "step2";
    private final String STEP3 = "step3";
    private final String STEP4 = "step4";
    private final String STEP5 = "step5";
    private final String STEP6 = "step6";
    private String mAppName = HuaweiTool.getAppName();
    private HashMap<String, String> mStepMap = new HashMap();
    private boolean result = false;

    public boolean modify(AccessibilityNodeInfo accessibilityNodeInfo, AccessibilityService accessibilityService) {
        if (this.result) {
            return true;
        }
        if (NodeUtil.pageContains(accessibilityNodeInfo, "可修改系统设置") || NodeUtil.pageContains(accessibilityNodeInfo, "修改系统设置")) {
            if (CallerShowUtils.checkSysModifyPermission(HuaweiTool.getContent())) {
                this.result = true;
                HuaweiTool.actionModitySystemDone();
                NodeUtil.back(accessibilityService);
            } else if (this.mStepMap.containsKey("step1")) {
                this.result = true;
                HuaweiTool.actionModitySystemDone();
                NodeUtil.back(accessibilityService);
            } else if (!this.mStepMap.containsKey("step1")) {
                this.mStepMap.put("step1", "");
                HuaweiActionUtil.performSwitch(accessibilityNodeInfo, HuaweiTool.getString(R.string.allow_edit_sys_settings));
            }
        }
        return false;
    }
}
